package com.uzhie.web.controller.http;

import com.alibaba.fastjson.JSONObject;
import com.uzhie.web.anno.Auth;
import com.uzhie.web.bean.PageBean;
import com.uzhie.web.bean.PayloadBean;
import com.uzhie.web.controller.http.comm.CommController;
import com.uzhie.web.module.VideoMonitorReport;
import com.uzhie.web.service.VideoMonitorReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;


/**
 * 客户端视频
 * Created by lilongfei on 2018/7/24.
 */
@Controller
@RequestMapping(value = "videoMonitor")
public class VideoMonitorReportController extends CommController {

    @Autowired
    private VideoMonitorReportService videoMonitorReportService;

    /**
     * @param body
     * @return
     */
    @Auth
    @ResponseBody
    @RequestMapping(value = "report")
    public PayloadBean selectAllVideoMonitor(@RequestBody(required = false) JSONObject body, @RequestBody(required = false) PageBean page) {
        try {
            String vehicleNumber = body.getString("vehicleNumber");
            String beginTime = body.getString("beginTime");
            String endTime = body.getString("endTime");
            List<VideoMonitorReport> result = videoMonitorReportService.selectAllVideoMonitor(beginTime, endTime, vehicleNumber, page);
            return buildResponseWithPage(result, page);
        } catch (IllegalArgumentException e) {
            return buildResponseWithPage(null, page, e.getMessage());
        }
    }

}
